using System.IO;
using System.Net.Mail;

namespace Headspring.Training.Core.Services.Impl
{
	public class SmtpNotifier : INotifier
	{
		private readonly SmtpClient _smtpClient = new SmtpClient();

		public void Send(string emailAddress, string emailText)
		{
			var message = new MailMessage("no-reply@google.com", emailAddress);
			message.Subject = "notification";
			message.IsBodyHtml = true;
			message.Body = emailText;

			sendMailMessage(message, _smtpClient);
		}

		protected virtual void sendMailMessage(MailMessage message,
		                                       SmtpClient client)
		{
			client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
			client.PickupDirectoryLocation = Directory.GetCurrentDirectory();
			client.Send(message);
		}
	}
}